<?php
namespace  App\Http\Controllers\AliPay;

use App\Common\AlipayConfig;
use App\Http\Controllers\AliPay\AliPaySubmitController;
use App\Http\Controllers\Controller;

/**
 * Class AliPayRequestController
 * @package App\Http\Controllers\AliPay
 * 阿里请求接口
 */
class AliPayRequestController extends Controller
{
    var $config = null;
    public function __construct()
    {
        header("Content-type:text/html;charset=utf-8");
        $this->config = new AlipayConfig();
    }

    /**
     * @param null $order_no
     * @param null $price
     *发送请求
     */
    public function SendRequest($order_no=null,$price=null)
    {

        $subject = "动态IP套餐";
        $body="动态IP套餐。";

        /************************************************************/

        //构造要请求的参数数组，无需改动
        $parameter = array(
            "service"       => $this->config->service,
            "partner"       => $this->config->partner,
            "seller_id"  => $this->config->seller_id,
            "payment_type"	=> $this->config->payment_type,
            "notify_url"	=> $this->config->notify_url,
            "return_url"	=>$this->config->return_url,

            "anti_phishing_key"=>$this->config->anti_phishing_key,
            "exter_invoke_ip"=>$this->config->exter_invoke_ip,
            "out_trade_no"	=> $order_no,
            "subject"	=> $subject,
            "total_fee"	=> $price,
            "body"	=> $body,
            "_input_charset"	=> trim(strtolower('utf-8'))
            //其他业务参数根据在线开发文档，添加参数.文档地址:https://doc.open.alipay.com/doc2/detail.htm?spm=a219a.7629140.0.0.kiX33I&treeId=62&articleId=103740&docType=1
            //如"参数名"=>"参数值"
        );


        $alipay_config = [];
        $alipay_config['sign_type'] = $this->config->sign_type;     //  签名方式
        $alipay_config['input_charset'] = 'utf-8';     //字符集
        $alipay_config['partner'] = $this->config->partner;             //合作身份者ID;

        //建立请求
        $alipaySubmit = new AliPaySubmitController($alipay_config);

        $html_text = $alipaySubmit->buildRequestForm($parameter,"get", "确认");
        return  $html_text;

    }







}

